<?php

namespace app\common\model;

use think\Model;


class Banner extends Model
{





    // 表名
    protected $name = 'banner';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'url_str',
        'poster_str',
    ];
    public function getPosterStrAttr($v, $d)
    {
        return $d['poster'] ? cdnurl($d['poster'], true) : '';
    }
    public function getUrlStrAttr($v, $d)
    {
        return $d['url'] ? cdnurl($d['url'], true) : '';
    }

    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}
